% GAUTIER LE BIHAN - 2020
% Replication files for "Shocks vs Menu Costs: Patterns of Price Rigidity in an Estimated Multi-Sector 
% Menu-Cost Model" Review of Economics and Statistics
% File:identif_univ_CalvoPlus.m
% This code Generates Figure 1 in paper from stored simulated data (�\Simu_identification\simu_univ_CalvoPlus\stat_outsample_19.mat)

clear all
close all
clear matrix
clc

cd ..\..\Simu_identification\simu_univ_CalvoPlus
load stat_outsample_19.mat 

stat_outsampleb=stat_outsample_19(:,1:end)


%% The first 4 columns are the parameters
params_vec=stat_outsampleb(:, 1:3)   ;
%% The first folllowing columns are the moments
moments_vec=stat_outsampleb(:, 5:end)  ;


%%%
disp( '%%%%%%%%%%%%%%%%    Parameters value for the baseline case   %%%%%%%%%%%%%%%%%%%%%%%%%%');
% param0=[0.0502 ;0.0307; 0.0353 ;0.694600000000000];*/
rho_base =0.694600000000000
p0_base = 0.0502
mu_c_base =0.0307
sig_eps_a_base = 0.0353


%%%
%%% VARYING P0
%%%

param_plot = 1;

FFF=figure(1);
%%% Vector of p0, holding other parameters to their default values
aa = abs(params_vec(:,2)-mu_c_base );
aa_min = min(aa);
cc = abs(params_vec(:,3)-sig_eps_a_base );
cc_min = min(cc);
%dd = abs(params_vec(:,4)-rho_base );
%dd_min = min(dd);

plot_vec = (aa==aa_min)&(cc==cc_min);%&(dd==dd_min);


%%% Plot
subplot(3,5,1)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,1), '-k')
plot([p0_base p0_base],[0 0.2], '--k');
axis([min(params_vec(:,1)) max(params_vec(:,1)) 0 0.2])
xlabel('\lambda') % x-axis label
ylabel('Freq. Changes') % y-axis label
hold off;


subplot(3,5,2)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,2), '-k')
plot([p0_base p0_base],[0.5 0.8], '--k');
axis([min(params_vec(:,1)) max(params_vec(:,1))  0.5 0.8])
xlabel('\lambda') % x-axis label
ylabel('Share of increases') % y-axis label
hold off;

subplot(3,5,3)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,3), '-k')
plot([p0_base p0_base],[0 0.08], '--k');
axis([min(params_vec(:,1)) max(params_vec(:,1))  0.0 0.08])
xlabel('\lambda') % x-axis label
ylabel('Median') % y-axis label
hold off;

subplot(3,5,4)
hold on;plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,4), '-k')
plot([p0_base p0_base],[0 0.15], '--k');
axis([min(params_vec(:,1)) max(params_vec(:,1))  0.0 0.15])
xlabel('\lambda') % x-axis label
ylabel('Interquartile') % y-axis label
hold off;

subplot(3,5,5)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,5), '-k')
plot([p0_base p0_base],[0 4], '--k');
axis([min(params_vec(:,1)) max(params_vec(:,1))  0 4])
xlabel('\lambda') % x-axis label
ylabel('Kurtosis') % y-axis label
hold off;




param_plot = 2;
%%% Vector of mu_c, holding other parameters to their default values
aa = abs(params_vec(:,1)- p0_base);
aa_min = min(aa);
% bb = abs(params_vec(:,3)-sig_c_base );
% bb_min = min(bb);
cc = abs(params_vec(:,3)-sig_eps_a_base );
cc_min = min(cc);
%dd = abs(params_vec(:,4)-rho_base );
%dd_min = min(dd);
plot_vec = (aa==aa_min)&(cc==cc_min);%&(dd==dd_min);


subplot(3,5,6)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,1), '-k');
plot([mu_c_base mu_c_base],[0 0.2], '--k');
axis([min(params_vec(:,2)) max(params_vec(:,2)) 0 0.20])
xlabel('\mu') % x-axis label
ylabel('Freq. Changes') % y-axis label
hold off;

subplot(3,5,7)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,2), '-k');
plot([mu_c_base mu_c_base],[0.5 0.8], '--k');
axis([min(params_vec(:,2)) max(params_vec(:,2)) 0.5 0.8])
xlabel('\mu') % x-axis label
ylabel('Share of increases') % y-axis label
hold off;

subplot(3,5,8)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,3), '-k');
plot([mu_c_base mu_c_base],[0 0.08], '--k');
axis([min(params_vec(:,2)) max(params_vec(:,2))  0.0 0.08])
xlabel('\mu') % x-axis label
ylabel('Median') % y-axis label
hold off;

subplot(3,5,9)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,4), '-k');
plot([mu_c_base mu_c_base],[0 0.15], '--k');
axis([min(params_vec(:,2)) max(params_vec(:,2))  0.0 0.15])
xlabel('\mu') % x-axis label
ylabel('Interquartile') % y-axis label
hold off;

subplot(3,5,10)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,5), '-k');
plot([mu_c_base mu_c_base],[0 4], '--k');
axis([min(params_vec(:,2)) max(params_vec(:,2))  0 4])
xlabel('\mu') % x-axis label
ylabel('Kurtosis') % y-axis label
hold off;


%figure(2);
param_plot = 3;
%%% Vector of mu_c, holding other parameters to their default values
aa = abs(params_vec(:,1)- p0_base);
aa_min = min(aa);
% bb = abs(params_vec(:,3)-sig_c_base );
% bb_min = min(bb);
cc = abs(params_vec(:,2)-mu_c_base );
cc_min = min(cc);
%dd = abs(params_vec(:,4)-rho_base );
%dd_min = min(dd);
plot_vec = (aa==aa_min)&(cc==cc_min)%&(dd==dd_min);


subplot(3,5,11)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,1), '-k');
plot([sig_eps_a_base sig_eps_a_base],[0 0.2], '--k');
axis([min(params_vec(:,3)) 0.05   0. 0.2])
xlabel('\sigma') % x-axis label
ylabel('Freq. changes') % y-axis label
hold off;

subplot(3,5,12)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,2), '-k');
plot([sig_eps_a_base sig_eps_a_base],[0.5 0.8], '--k');
axis([min(params_vec(:,3)) 0.05   0.5 0.8])
xlabel('\sigma') % x-axis label
ylabel('Share of increases') % y-axis label
hold off;

subplot(3,5,13)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,3), '-k');
plot([sig_eps_a_base sig_eps_a_base],[0 0.08], '--k');
axis([min(params_vec(:,3)) 0.05   0 0.08])
xlabel('\sigma') % x-axis label
ylabel('Median') % y-axis label
hold off

subplot(3,5,14)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,4), '-k');
plot([sig_eps_a_base sig_eps_a_base],[0.0 0.15], '--k');
axis([min(params_vec(:,3)) 0.05   0.0 0.15])
xlabel('\sigma') % x-axis label
ylabel('Interquartile') % y-axis label
hold off;

subplot(3,5,15)
hold on;
plot(params_vec(plot_vec~=0,param_plot),moments_vec(plot_vec~=0,5), '-k');
plot([sig_eps_a_base sig_eps_a_base],[0 4], '--k');
axis([min(params_vec(:,3)) 0.05  0 4])
xlabel('\sigma') % x-axis label
ylabel('Kurtosis') % y-axis label
hold off;

% Exporting file
print('..\..\..\figures\figure1','-depsc')

orient(FFF,'landscape')
  print('..\..\..\figures\figure1.pdf','-dpdf','-fillpage')

